# Contributor: Duncan Bellamy <dunk@denkimushi.com>
# Maintainer: Duncan Bellamy <dunk@denkimushi.com>
pkgname=xnvme
pkgver=0.7.3
pkgrel=0
pkgdesc="cross-platform libraries and tools for NVMe devices"
url="https://xnvme.io"
# 32bit unsupported
arch="all !armhf !armv7 !x86"
license="BSD-3-Clause"
makedepends="bsd-compat-headers libaio-dev liburing-dev linux-headers meson py3-gpep517 py3-setuptools py3-wheel"
subpackages="py3-$pkgname-pyc py3-$pkgname:_python:noarch $pkgname-dev $pkgname-doc"
source="$pkgname-$pkgver.tar.gz::https://github.com/OpenMPDK/xNVMe/archive/refs/tags/v$pkgver.tar.gz"
builddir="$srcdir/xNVMe-$pkgver"
case "$CARCH" in
aarch64|x86_64) makedepends="$makedepends libvfn-dev" ;;
esac

build() {
	abuild-meson -Dexamples=false -Dwith-spdk=false \
		. output
	meson compile -C output

	cd python/bindings
	gpep517 build-wheel \
		--wheel-dir .dist \
		--output-fd 3 3>&1 >&2
}

check() {
	meson test --no-rebuild --print-errorlogs -C output
}

package() {
	DESTDIR="$pkgdir" meson install --no-rebuild -C output

	cd python/bindings
	python3 -m installer -d "$pkgdir" \
		.dist/*.whl
	rm -r "$pkgdir"/usr/lib/python3*/site-packages/xnvme/ctypes_bindings/tests
}

_python() {
	amove usr/lib/python*
}

sha512sums="
4fc66f0aebb5e40b67c1daeb3e2e9b757fd8ffa74aeefbe3fe2ebc16103797781c9823492e3750201053cf582ea54dae3ceee56dee3c003bf0ab8f91de6ae8ce  xnvme-0.7.3.tar.gz
"
